package com.qujia.customer.service.impl;
import com.qujia.customer.domain.CustomerCardSettingDetailContent;
import com.qujia.customer.mapper.CustomerCardSettingDetailContentMapper;
import com.qujia.customer.service.CustomerCardSettingDetailContentService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CustomerCardSettingDetailContent)表服务实现类
 *
 * @author makejava
 * @since 2023-09-11 10:38:19
 */
@Service("customerCardSettingDetailContentService")
public class CustomerCardSettingDetailContentServiceImpl implements CustomerCardSettingDetailContentService {
    @Resource
    private CustomerCardSettingDetailContentMapper customerCardSettingDetailContentMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param ccsdcId 主键
     * @return 实例对象
     */
    @Override
    public CustomerCardSettingDetailContent queryById(Long ccsdcId) {
        return this.customerCardSettingDetailContentMapper.queryById(ccsdcId);
    }

    /**
     *  分页查询
     *
     * @param customerCardSettingDetailContent 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<CustomerCardSettingDetailContent> queryByPage(CustomerCardSettingDetailContent customerCardSettingDetailContent, PageRequest pageRequest) {
        long total = this.customerCardSettingDetailContentMapper.count(customerCardSettingDetailContent);
        return new PageImpl<>(this.customerCardSettingDetailContentMapper.queryAllByLimit(customerCardSettingDetailContent, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param customerCardSettingDetailContent 实例对象
     * @return 实例对象
     */
    @Override
    public CustomerCardSettingDetailContent insert(CustomerCardSettingDetailContent customerCardSettingDetailContent) {
        this.customerCardSettingDetailContentMapper.insert(customerCardSettingDetailContent);
        return customerCardSettingDetailContent;
    }

    /**
     * 修改数据
     *
     * @param customerCardSettingDetailContent 实例对象
     * @return 实例对象
     */
    @Override
    public CustomerCardSettingDetailContent update(CustomerCardSettingDetailContent customerCardSettingDetailContent) {
        this.customerCardSettingDetailContentMapper.update(customerCardSettingDetailContent);
        return this.queryById(customerCardSettingDetailContent.getCcsdcId());
    }

    /**
     * 通过主键删除数据
     *
     * @param ccsdcId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long ccsdcId) {
        return this.customerCardSettingDetailContentMapper.deleteById(ccsdcId) > 0;
    }

    @Override
    public Integer updateByCcsdId(CustomerCardSettingDetailContent detailContent) {
        return this.customerCardSettingDetailContentMapper.updateByCcsdId(detailContent);
    }

    @Override
    public List<CustomerCardSettingDetailContent> query(CustomerCardSettingDetailContent customerCardSettingDetailContent) {
        return this.customerCardSettingDetailContentMapper.query(customerCardSettingDetailContent);
    }

    @Override
    public List<CustomerCardSettingDetailContent> getCustomerCardSettingDetailContentListByStationId(Long stationId) {
        return null;
    }
}
